package cn.edu.leetcode.其他;

public class Excel表列序号 {
    public static void main(String[] args) {
        System.out.println(titleToNumber("AA"));
    }

    public static int titleToNumber(String columnTitle) {
        char[] chars = columnTitle.toCharArray();
        int number = 0;

        for (char aChar : chars) {
            number *= 26;
            number += aChar - 'A' + 1;
        }

        return number;
    }
}
